﻿using OKDebug.webservice;
using System;
using System.Linq;
using System.Windows.Forms;

namespace OKDebug
{
    public partial class FrmWebservice : Form
    {
        public FrmWebservice()
        {
            InitializeComponent();
        }

        private void btnPost_Click(object sender, EventArgs e)
        {
            string url = txtUrl.Text.Trim();
            string apiName = txtApiName.Text.Trim();
            string pars = txtPars.Text.Trim();
            if (string.IsNullOrEmpty(apiName))
            {
                MessageBox.Show("方法名空");
                return;
            }

            if (string.IsNullOrEmpty(url))
            {
                MessageBox.Show("url空");
                return;
            }

            WebserviceHelper webserviceHelper = new WebserviceHelper();
            object[] pararr = { };
            if (!string.IsNullOrEmpty(pars))
            {
                pararr = pars.Split('|');
            }

            var wsResult = webserviceHelper.CallWebservice(url, apiName, parameters: pararr);
            if (!wsResult.IsSuccess)
            {
                MessageBox.Show(wsResult.Message);
                return;
            }

            txtRsp.Text = wsResult.Result;
        }
    }
}
